#!/bin/bash

# 心跳客户端Demo启动脚本

echo "=== 心跳客户端Demo ==="
echo "请确保Controller服务正在运行 (http://localhost:57675)"
echo ""

# 检查Python环境
if ! command -v python3 &> /dev/null; then
    echo "错误: 未找到python3命令"
    exit 1
fi

# 检查依赖
echo "检查依赖..."
python3 -c "import requests" 2>/dev/null || {
    echo "错误: 缺少requests库，请运行: pip install requests"
    exit 1
}

# 设置工作目录
cd "$(dirname "$0")"

echo "选择要运行的Demo:"
echo "1. 简单心跳示例 (simple_heartbeat_example.py)"
echo "2. 完整功能心跳客户端 (heartbeat_client_demo.py)"
echo ""

read -p "请输入选择 (1-2): " choice

case $choice in
    1)
        echo "启动简单心跳示例..."
        python3 simple_heartbeat_example.py
        ;;
    2)
        echo "启动完整功能心跳客户端..."
        python3 heartbeat_client_demo.py
        ;;
    *)
        echo "无效选择，启动简单心跳示例..."
        python3 simple_heartbeat_example.py
        ;;
esac
